﻿<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>


    {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}
</head>
<body>
<style>
    .layui-btn{height: 30px;line-height: 30px;}

</style>
<div class="newtest">

    {if condition="$library==5""}
        {include file="pro_config/header"/}
    {/if}


    <div class=" new_serach">
        <form class="layui-form layui-col-md12 x-so" name="searchForm">


            <span> {if condition="$library eq 6"}企业名称：{else/}项目名称：{/if}</span>
            <div class="layui-inline layui-form">
                <input class="layui-input" name="keyword" value=""  autocomplete="off">
            </div>


<!--            {if condition="$library eq 4 | $library eq 3"}-->
<!--                <span>项目代码</span>-->
<!--                <div class="layui-inline layui-form">-->
<!--                    <input class="layui-input" name="code" value="{$code}" autocomplete="off">-->
<!--                </div>-->
<!--            {/if}-->

            {if condition="$library eq 4"}
                <span>项目类别</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" name="project_type"  lay-search="">
                        <option value="">全部</option>
                        {volist name="type" id="vo"}
                        <option value="{$vo.id}" >{$vo.name}</option>
                        {/volist}
                    </select>
                </div>

                <span>项目建设性质</span>
                <div class="layui-inline layui-form">
                    <select name="nature">
                        <option value="0">全部</option>
                        <option value="新建" >新建</option>
                        <option value="改建"  >改建</option>
                        <option value="扩建" >扩建</option>
                        <option value="迁建" >迁建</option>
                    </select>
                </div>
            {/if}


            <span> 责任账号：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" lay-search="" name="duty_person">
                    <option value="">全部</option>
                    {volist name="account" id="vo"}
                    <option value="{$vo.name}"  >{$vo.name}</option>
                    {/volist}
                </select>
            </div>



            {if condition="$library eq 4"}
                <span> 县级领导：</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" lay-search="" name="leader">
                        <option value="">全部</option>
                        {volist name="account" id="vo"}
                        <option value="{$vo.name}">{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
                <span> 项目状态：</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" name="project_status">
                        <option value="">全部</option>
                        <option value="1">待开工</option>
                        <option value="5">基础开工</option>
                        <option value="6">主体开工</option>
                        <option value="2">逾期</option>
                        <option value="3">已竣工</option>
                        <option value="4">暂缓推进</option>
                        <!--<option value="2" {if condition="$project_status eq 5"} selected {/if}>待开工</option>-->

                    </select>
                </div>
            {/if}


            <div {if condition="$library neq 1"} style="display: none" {/if}>
                <span>签约状态：</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" name="sign">
                        <option value="">全部</option>
                        <option value="5" >在谈项目</option>
                        <option value="1" >待签约</option>
                        <option value="2" >已签约</option>
                        <option value="3" >已逾期</option>
                        <option value="4" >暂缓推进</option>
                    </select>
                </div>
            </div>

            {if condition="$library eq 2"}
                <span>开工状态：</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" name="start_status">
                        <option value="">全部</option>
                        <option value="1" >待开工</option>
                        <option value="2" >已开工</option>
                        <option value="3" >已逾期</option>
                        <option value="4">暂缓推进</option>
                    </select>
                </div>
                <span>项目分组：</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" name="pro_group">
                        <option value="">全部</option>
                        {volist name="pro_group" id="vo"}
                            <option value="{$key}" >{$vo}</option>
                        {/volist}
                    </select>
                </div>
            {/if}

            <div {if condition="$library neq 3"} style="display: none" {/if}>
            <span>入库状态：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" name="warehousing">
                    <option value="">全部</option>
                    <option value="1" >待入库</option>
                    <option value="2" >已入库</option>
                </select>
            </div>
            </div>

            {if condition="$library eq 3"}
                <div >
                    <span>项目状态：</span>
                    <div class="layui-inline layui-form">
                        <select class="layui-select" name="project_status">
                            <option value="">全部</option>
                            <option value="1" >基础开工</option>
                            <option value="2">已竣工</option>
                            <option value="3" >主体开工</option>
                            <option value="4">暂缓推进</option>
                        </select>
                    </div>
                </div>

                <span>计划类别</span>
                <div class="layui-inline layui-form">
                    <select class="layui-select" name="plan_category"  lay-search="">
                        <option value="">全部</option>
                        {volist name="plan_category" id="vo"}
                        <option value="{$key}" >{$vo}</option>
                        {/volist}
                    </select>
                </div>


            {/if}


            {if condition="$library eq 3 | $library eq 2"}
            <span>项目类别</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" name="project_type"  lay-search="">
                    <option value="">全部</option>
                    {volist name="type" id="vo"}
                    <option value="{$vo.id}" >{$vo.name}</option>
                    {/volist}
                </select>
            </div>
            {/if}


            <div {if condition="$library neq 5"} style="display: none" {/if}>
            <span> 启报状态：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" name="reply">
                    <option value="">全部</option>
                    <option value="1">待启报</option>
                    <option value="2">已启报</option>
                </select>
            </div>
            </div>

            <!--<div {if condition="$library neq 6"} style="display: none" {/if}>-->
            <!--<span> 运营情况：</span>-->
            <!--<div class="layui-inline layui-form">-->
                <!--<select class="layui-select" name="operation">-->
                    <!--<option value="">全部</option>-->
                    <!--<option value="1">正常</option>-->
                    <!--<option value="2">异常</option>-->
                <!--</select>-->
            <!--</div>-->
            <!--</div>-->

            <div {if condition="$library neq 6"} style="display: none" {/if}>
            <span> 运行情况：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" name="condition_val">
                    <option value="">全部</option>
                    <option value="1" >运行正常</option>
                    <option value="2" >困难</option>
<!--                    <option value="3" {if condition="$condition_val eq 3"} selected {/if}>特别困难</option>-->
                    <option value="4">停产</option>
                </select>
            </div>
            </div>





            <span> 责任单位：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" lay-search="" name="duty_unit">
                <option value="">全部</option>
                {volist name="project_dictionaries" id="vo"}
                    <option value="{$vo.name}" >{$vo.name}</option>
                {/volist}
            </select>
            </div>

            <!--<div {if condition="$library eq 6"} style="display: none" {/if}>-->
                    <!--<span> 项目类别：</span>-->
                    <!--<div class="layui-inline layui-form">-->
                        <!--<select class="layui-select" name="project_type"  lay-search="">-->
                            <!--<option value="">全部</option>-->
                            <!--{volist name="type" id="vo"}-->
                            <!--<option value="{$vo.id}">{$vo.name}</option>-->
                            <!--{/volist}-->
                        <!--</select>-->
                        <!--</select>-->
                    <!--</div>-->
            <!--</div>-->

            <span> 所属产业链：</span>
            <div class="layui-inline layui-form">
                <select name="typeId"  lay-search="" >
                    <option value="0">全部</option>
                    {volist name="IndustrialChain" id="vo"}
                    <option value="{$vo.value}">{$vo.title}</option>
                    {/volist}
                </select>
            </div>

            {if condition="$library eq 6"}
            <span> 一级分类：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" name="menuTop" lay-verify="menuTop" lay-filter="menuTop">
                    <option value="">全部</option>
                    <option value="1" >培育类</option>
                    <option value="2" >四上类</option>
                </select>
            </div>

            <span> 企业类型：</span>
            <div class="layui-inline layui-form">
                <select class="layui-select" name="enterprise">
                    <option value="0">请选择一级分类</option>
                </select>
            </div>

            <span>存在的问题：</span>
            <div class="layui-inline layui-form">
                <input class="layui-input" name="visit_remark" autocomplete="off" value="">
            </div>

            <span>年份：</span>
            <div class="layui-inline layui-form">
                <input class="layui-input year" name="year" autocomplete="off" >
            </div>

            <span>月份：</span>
            <div class="layui-inline layui-form">
                <select name="month">
                    <option value="0">全部</option>
                    <option value="01">1月</option>
                    <option value="02">2月</option>
                    <option value="03">3月</option>
                    <option value="04">4月</option>
                    <option value="05">5月</option>
                    <option value="06">6月</option>
                    <option value="07">7月</option>
                    <option value="08">8月</option>
                    <option value="09">9月</option>
                    <option value="10">10月</option>
                    <option value="11">11月</option>
                    <option value="12">12月</option>
                </select>
            </div>
            {/if}


            <input type="hidden" name="parent_id" value="{$parent_id}">

            <button class="layui-btn serach_btn" type="button" ><i class="layui-icon">&#xe615;</i></button>
            <button class="layui-btn layui-btn-primary" type="reset" id="reset">重置</button>
        </form>
    </div>

    <!--导入按钮-->
    <button type="button" class="layui-btn-sm layui-btn" id="test3" lay-event="upload" style="display: none" ></button>

    <div class="new_main">

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <a class="layui-btn-sm layui-btn"  href="{:URL('project/index/detail')}?library={$library}&parent_id={$parent_id}" >添加项目</a>

                <button type="button" class="layui-btn-sm layui-btn" lay-event="upload" ><i class="layui-icon"></i>导入项目</button>

                <a class="layui-btn-sm layui-btn" href="/template{$library}.xls">模板下载</a>

                <a class="layui-btn-sm layui-btn layui-btn-danger" lay-event="getCheckLength">批量删除</a>

                {if condition="$library==2 | $library==3"}
                    <a class="layui-btn-sm layui-btn" lay-event="getBatch">批量操作</a>
                {/if}

                {if condition="$library!=6"}
                <button class="layui-btn-sm layui-btn" lay-event="export" >导出</button>
                {else/}
                <button class="layui-btn-sm layui-btn" lay-event="sqkExcel" >导出</button>
                {/if}
            </div>
        </script>


        <table class="layui-hide" id="demo" lay-filter="demo"></table>

        <script type="text/html" id="switchTpl">
            <!--启用禁用操作-->
            <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="启用|禁用" lay-filter="sexDemo" {{ d.status == 1 ? 'checked' : '' }}>
        </script>

        <script type="text/html" id="title">
           <a style="color: #0b6fff" lay-event="title" >{{d.title}}</a>
        </script>

        <script type="text/html" id="parentName">
<!--           <a style="color: #0b6fff" lay-event="parentName" ></a>-->
            <a class="layui-btn" lay-event="subordinate">下级项目【{{d.parentCount}}】</a>
        </script>

        <script type="text/html" id="signTime">
            {{#  if(d.signDays > 0 & d.signDays<=3){ }}
            <a style="color: red" >{{d.signTime}}</a>
            {{#  }else{ }}
            <a style="color: #0b6fff"  >{{d.signTime}}</a>
            {{#  } }}
        </script>

        <script type="text/html" id="plan_onstream_time">
            {{#  if(d.onstreamTimeDays > 0 & d.onstreamTimeDays<=3){ }}
            <a style="color: red" >{{d.plan_onstream_time}}</a>
            {{#  }else{ }}
            <a style="color: #0b6fff" >{{d.plan_onstream_time}}</a>
            {{#  } }}
        </script>

        <script type="text/html" id="plan_complete_time">
            {{#  if(d.completeTimeDays > 0 & d.completeTimeDays<=3){ }}
            <a style="color: red" >{{d.plan_complete_time}}</a>
            {{#  }else{ }}
            <a style="color: #0b6fff" >{{d.plan_complete_time}}</a>
            {{#  } }}
        </script>




        <script type="text/html" id="signTpl">
            {{#  if(d.sign == '1'){ }}
            <a style="color: #0b6fff" lay-event="sign" >待签约</a>
            {{#  } }}
            {{#  if(d.sign == '2'){ }}
            <a style="color: #0b6fff" lay-event="sign" >已签约</a>
            {{#  } }}
            {{#  if(d.sign == '3'){ }}
            <a style="color: #0b6fff" lay-event="sign" >已逾期</a>
            {{#  } }}
            {{#  if(d.sign == '4'){ }}
            <a style="color: #0b6fff" lay-event="sign" >暂缓推进项目</a>
            {{#  } }}
            {{#  if(d.sign == '5'){ }}
            <a style="color: #0b6fff" lay-event="sign" >在谈项目</a>
            {{#  } }}
        </script>

        <script type="text/html" id="statusTpl">
            {{#  if(d.project_status == '0'){ }}
            <a style="color: #0b6fff" lay-event="setup" >待开工</a>
            {{#  }  }}

            {{#  if(d.project_status == '1'){ }}
            <a style="color: #0b6fff" lay-event="setup" >逾期</a>
            {{#  }  }}

            {{#  if(d.project_status == '2'){ }}
            <a style="color: #0b6fff" lay-event="setup" >已竣工</a>
            {{#  }  }}

            {{#  if(d.project_status == '3'){ }}
            <a style="color: #0b6fff" lay-event="setup" >暂缓推进</a>
            {{#  }  }}

            {{#  if(d.project_status == '4'){ }}
            <a style="color: #0b6fff" lay-event="setup" >基础开工</a>
            {{#  }  }}

            {{#  if(d.project_status == '5'){ }}
            <a style="color: #0b6fff" lay-event="setup" >主体开工</a>
            {{#  }  }}
        </script>

        <script type="text/html" id="replyStatusTpl">

            {{#  if(d.project_status == '0'){ }}
             <a style="color: #0b6fff" lay-event="replyStatus" >基础开工</a>
            {{#  } else if(d.project_status=='1'){ }}
                <a style="color: #0b6fff" lay-event="replyStatus" >已竣工</a>
            {{#  } else if(d.project_status=='2'){ }}
                <a style="color: #0b6fff" lay-event="replyStatus" >主体开工</a>
            {{#  } else if(d.project_status=='3'){ }}
                <a style="color: #0b6fff" lay-event="replyStatus" >暂缓推进</a>
            {{#  } else { }}
                <a style="color: #0b6fff" lay-event="replyStatus" >编辑状态</a>
            {{#  } }}



        </script>

        <script type="text/html" id="startTpl">
            {{#  if(d.start_status == '1'){ }}
            <a style="color: #0b6fff" lay-event="start_status" >待开工</a>
            {{#  }  }}
            {{#  if(d.start_status == '2'){ }}
            <a style="color: #0b6fff" lay-event="start_status" >已开工</a>
            {{#  }  }}
            {{#  if(d.start_status == '3'){ }}
            <a style="color: #0b6fff" lay-event="start_status" >已逾期</a>
            {{#  }  }}
            {{#  if(d.start_status == '4'){ }}
            <a style="color: #0b6fff" lay-event="start_status" >暂缓推进</a>
            {{#  }  }}
        </script>

        <script type="text/html" id="warehousingTpl">
            <a style="color: #0b6fff" lay-event="warehousing" >{{d.warehousing}}</a>
            <!--{{#  if(d.warehousing == '1'){ }}-->
           <!---->
            <!--{{#  } else { }}-->
            <!--<a style="color: #0b6fff" lay-event="warehousing" >已入库</a>-->
            <!--{{#  } }}-->
        </script>

        <script type="text/html" id="replyTpl">
            {{#  if(d.reply == '1'){ }}
            <a style="color: #0b6fff" lay-event="reply" >已启报</a>
            {{#  } else if(d.reply=='2'){ }}
            <a style="color: #0b6fff" lay-event="reply" >已报竭</a>
            {{#  } else { }}
            <a style="color: #0b6fff" lay-event="reply" >已报竭</a>
            {{#  } }}
        </script>

        <script type="text/html" id="operationTpl">
            {{#  if(d.operation == '1'){ }}
            <a style="color: #0b6fff" >正常</a>
            {{#  } else { }}
            <a style="color: #ff0b0b" >异常</a>
            {{#  } }}
        </script>
        
        <script type="text/html" id="operationTpl1">
            {{#  if(d.condition_val == '1'){ }}
            <a style="color: #0b6fff" >正常</a>
             {{#  } else if(d.condition_val=='2'){ }}
            <a style="color: #ff0b0b" >困难</a>
            {{#  } else { }}
              <a style="color: #ff0b0b" >停产</a>
            {{#  } }}
        </script>

<!--        <script type="text/html" id="overseerTpl">-->
<!--            <button class="layui-btn layui-btn-sm" lay-event="overseerList" data-val="2">督查概况</button>-->
<!--        </script>-->

        <script type="text/html" id="barDemo">
            {if condition="$library eq 6"}
            {{#  if(d.menuTop == 1){ }}
            <button class="layui-btn layui-btn-sm" lay-event="taxableIncome">应税收入</button>
            {{#  }  }}
            {/if}
            {if condition="$library eq 5"}
            <button class="layui-btn layui-btn-sm" lay-event="fixed">固投情况</button>
            {/if}

            <!--{if condition="$library eq 6"}-->
            <!--<button class="layui-btn layui-btn-sm" lay-event="remind">消息提醒</button>-->
            <!--{/if}-->

            {if condition="$library eq 2 || $library eq 3"}
                {{#  if(d.progressCount > 0){ }}
                <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="progressList" data-val="2">进展情况</button>
                {{#  } else { }}
                <button class="layui-btn layui-btn-sm" lay-event="progressList" data-val="2">进展情况</button>
                {{#  } }}
            {/if}

            {if condition="$library eq 4"}

            {{#  if(d.progressCount > 0){ }}
                <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="progressList" data-val="1">进展情况</button>
            {{#  } else { }}
                <button class="layui-btn layui-btn-sm" lay-event="progressList" data-val="1">进展情况</button>
            {{#  } }}


            {/if}

            {if condition="$library eq 2 || $library eq 4|| $library eq 3|| $library eq 1"}
                {{#  if(d.advanceCount > 0){ }}
                    <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="advance">节点计划</button>
                {{#  } else { }}
                    <button class="layui-btn layui-btn-sm" lay-event="advance">节点计划</button>
                {{#  } }}
                <button class="layui-btn layui-btn-sm" lay-event="progressList" data-val="4">情况说明</button>
            {/if}

            {if condition="$library eq 1"}
                {{#  if(d.progressCount > 0){ }}
                <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="progressList" data-val="1">进展情况</button>
                {{#  } else { }}
                <button class="layui-btn layui-btn-sm" lay-event="progressList" data-val="1">进展情况</button>
                {{#  } }}

                <button class="layui-btn layui-btn-sm" lay-event="progressList" data-val="3">逾期说明</button>
            {/if}

            {if condition="$library neq 5"}
                {if condition="$library eq 1"}
                    <a class="layui-btn layui-btn-sm" href="{:URL('project/Figure/index')}?pro_id={{d.id}}&library={$library}">签约进度</a>
                {elseif condition="$library eq 2"}
                    <a class="layui-btn layui-btn-sm" href="{:URL('project/Figure/index')}?pro_id={{d.id}}&library={$library}">预备进展</a>
                {elseif condition="$library eq 6"}
                    <a class="layui-btn layui-btn-sm" href="{:URL('project/Figure/index')}?pro_id={{d.id}}&library={$library}">服务记录</a>
                {else/}
                    <a class="layui-btn layui-btn-sm {{#  if(d.figureCount > 0){ }}layui-btn-warm {{#  } }}" href="{:URL('project/Figure/index')}?pro_id={{d.id}}&library={$library}">项目进展</a>
                {/if}
            {/if}

            <a class="layui-btn layui-btn-sm  {{#  if(d.commentCount > 0){ }}layui-btn-warm {{#  } }}"  href="{:URL('project/Comment/index')}?pro_id={{d.id}}&library={$library}">领导点评</a>




            <a class="layui-btn layui-btn-sm" href="{:URL('project/index/detail')}?id={{d.id}}&library={$library}">修改</a>
            {if condition="($library eq 2 || $library eq 3 || $library eq 4)"}
            <a class="layui-btn-sm layui-btn"  href="{:URL('project/index/detail')}?library={$library}&isChild=1&parentId={{d.id}}" >添加子账目</a>
            {/if}
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</button>
        </script>
    </div>


</div>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<!--弹框js-->
<script src="/static/js/yii.js"></script>
<script>
    var library = {$library};
    var showPage = {$showPage};
    var modal=new yii.modal();
    layui.use(['form','jquery','layer','laydate','table','upload'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload;;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格

        $("#reset").click(function () {
            $("input[name='keyword']").attr("value","");
            $.ajax({
                type: "post",
                url: "{:URL('project/Communal/renderApi')}",
                data: {},
                dataType: "json",
                success: function (data) {

                }
            });
            form.render();
        })

        //日期范围
        laydate.render({
            elem: '#test6'
            , range: true
        });

        //日期范围
        laydate.render({
            elem: '.year'
            ,type:"year"

        });

        var pid = $("input[name='id']").val();
        var url = "{:URL('project/index/index')}?library="+library;
        //搜索操作
        $('.serach_btn').click(function () {
            var data=$("form[name='searchForm']").serializeArray();
            var dataVal = {};
            $.each(data, function(i, item){
                dataVal[item.name] = item.value;
            });
            var where = dataVal;

            // var keyword = $('input[name="keyword"]').val();
            // var where = {keyword:keyword,status:status,id:pid};
            search(table,url,where)
        });

        //列表
        var data=$("form[name='searchForm']").serializeArray();
        var dataVal = {type:'list',id:pid};
        $.each(data, function(i, item){
            dataVal[item.name] = item.value;
        });
        var where = dataVal;
        var title = "项目列表";


        table.on('sort(demo)', function(obj){ //注：sort 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            //尽管我们的 table 自带排序功能，但并没有请求服务端。
            //有些时候，你可能需要根据当前排序的字段，重新向服务端发送请求，从而实现服务端排序，如：
            // console.log(obj);return;
            var data=$("form[name='searchForm']").serializeArray();
            var dataVal = {};
            $.each(data, function(i, item){
                dataVal[item.name] = item.value;
            });
            dataVal['reorder'] = {type:obj.type,field:obj.field};
            var where = dataVal;
            search(table,url,where)

        });


        if(library==6){
            var cols = [[
                {type: 'checkbox', fixed: 'left'}
                // ,{field: 'id', title: 'ID',  sort: true, fixed: 'left',width:80, align:'center'}
                ,{field: 'title', title: '企业名称', align:'center',toolbar: '#title'},

                // ,{field: 'menuTop', title: '一级分类', align:'center'}
                // ,{field: 'enterprise', title: '企业类型', align:'center'}
                // ,{field: 'cultivation', title: '培育类别/企业状况', align:'center'}
                // ,{field: 'duty_unit', title: '责任单位', align:'center'}
                // ,{field: 'chargeman', title: '组长', align:'center'}
                // ,{field: 'member', title: '成员', align:'center'}
                // ,{field: 'liaison', title: '联络员及电话', align:'center'}
                // ,{field: 'operation', title: '是否运营正常', align:'center'}
                // ,{field: 'visit_time', title: '走访时间', align:'center'}
                // ,{field: 'visit_time', title: '走访情况', align:'center'}
                // ,{field: 'visit_remark', title: '存在的问题', align:'center'}
                // ,{field: 'remark', title: '备注', align:'center'}
                // ,{field: 'industry', title: '所属行业', align:'center'}
                // ,{field: 'product', title: '主要产品', align:'center'}
                // ,{field: 'revenue', title: '累计应税收入', align:'center'}
                // ,{field: 'gauge', title: '拟进规时间', align:'center'}


                // ,{field: 'duty_unit', title: '责任单位', align:'center'}
            ]];
        }else{
            var cols = [[
                {type: 'checkbox', fixed: 'left'},
                {field: 'title', title: '项目名称', align:'center',toolbar: '#title'}
                // ,{field: 'id', title: 'ID',  sort: true, fixed: 'left',width:80, align:'center'}
                // ,{field: 'title', title: '项目名称', align:'center',toolbar: '#title'}
                // ,{field: 'duty_unit', title: '责任单位', align:'center'}
                // ,{field: 'content', title: '内容', align:'center'}
            ]];

            if (library == 2 || library == 3 || library == 4) {
                cols[0].push(
                    {field: 'parent_name', title: '上级项目', align:'center',toolbar: '#parentName'}
                );
            }

            cols[0].push(
                {field: 'duty_unit', title: '责任单位', align:'center'}
            );
        }


        if(library==1){
            cols[0].push(
                {field: 'sign', title: '签约状态', align:'center',toolbar: '#signTpl'},
                {field: 'signTime', title: '计划签约时间',sort: true,toolbar: '#signTime'},
            );
        }
        if(library==2){
            cols[0].push(
                // {field: 'warehousing', title: '入库状态', align:'center',toolbar: '#warehousingTpl'},
                {field: 'start_status', title: '开工状态', align:'center',toolbar: '#startTpl'},
                {field: 'plan_onstream_time', title: '计划开工时间',sort: true,toolbar: '#plan_onstream_time'},
            );
        }

        if(library==3){
            cols[0].push(
                {field: 'warehousing', title: '入库状态', align:'center',toolbar: '#warehousingTpl'},
                {field: 'project_status', title: '项目状态 ', align:'center',toolbar: '#replyStatusTpl'},
                {field: 'plan_complete_time', title: '计划竣工时间',sort: true,toolbar: '#plan_complete_time'}
            );
        }
        if(library==4){
            cols[0].push(
                {field: 'warehousing', title: '入库状态', align:'center',toolbar: '#warehousingTpl'},
                {field: 'project_status', title: '项目状态', align:'center',toolbar: '#statusTpl'},
                {field: 'leader',title: '县级领导',align:'center'}
            );
        }
        if(library==5){
            cols[0].push(
                {field: 'reply', title: '入库状态 ', align:'center',toolbar: '#replyTpl'}

            );
        }

        if(library==6){
            cols[0].push(
                {field: 'operation', title: '运营情况 ', align:'center',toolbar: '#operationTpl'},
                {field: 'condition_val', title: '企业状况 ', align:'center',toolbar: '#operationTpl1'},
                {field: 'isUpdate', title: '是否更新 ', align:'center'},
            );
        }


        // if(library==1 | library==2 | library==3){
        //     cols[0].push(
        //         {field: 'operation', title: '督查概况 ', align:'center',toolbar: '#overseerTpl'},
        //     );
        // }

        if(library==6){
            cols[0].push(
                {field: 'sort', title: '排序',  align:'center',edit: 'number',width:60},
                // ,{field: 'status', title: '状态',templet: '#switchTpl', unresize: true, align:'center'}
                {field: 'addtime', title: '更新时间', align:'center',sort: true}
                ,{fixed: 'right',title: '操作', width:500, align:'center', toolbar: '#barDemo'}
            );
        }else{
            cols[0].push(
                {field: 'investment', title: '项目估算总投资（万元）', align:'center'}
                ,{field: 'sort', title: '排序',  align:'center',edit: 'number',width:60}
                ,{field: 'content',title: '建设规模及内容',align:'center'}
                // ,{field: 'difficulty',title: '存在问题', align:'center'}
                // ,{field: 'status', title: '状态',templet: '#switchTpl', unresize: true, align:'center'}
                ,{field: 'addtime', title: '更新时间', align:'center',sort: true}
                ,{fixed: 'right',title: '操作', width:500, align:'center', toolbar: '#barDemo'}
            );
        }



        showlist(table,url,where,title,cols,[10,20,50,100,200,500,1000],10,'#demo','#toolbarDemo',showPage);
        upload.render({
            elem: '#test3'
            ,url: "{:URL('project/Excel/picupload')}?library="+library //改成您自己的上传接口
            ,accept: 'file' //普通文件
            ,done: function(res){
                layer.msg(res.msg);
            }
        });

        $(".layui-laypage-skip").find("input").val(3 );
        $(".layui-laypage-btn").click();

        //监听行工具事件
        table.on('tool(demo)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'advance':
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['1000px','900px'],            //宽度450px,高自适应
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,
                        maxmin: true,
                        title: obj.data.title+"节点计划",
                        content:"{:URL('project/advancePlan/index')}?id="+id,
                        btn:['通知责任人','取消'],
                        btn1: function (index,layero) {
                            $.ajax({
                                type:'post',
                                url:"{:URL('project/Communal/sendSms')}",
                                data:{id:id,operation:"planCareful"},
                                dataType:'JSON',
                                success:function (res) {
                                    layer.alert(res.msg);
                                },
                                error:function (res) {
                                }
                            });


                        },
                    });
                    break;
                case 'remind': //消息提醒
                    layer.alert("功能开发中");
                    break;
                case 'title'://显示基本信息
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['800px', '65%'], //宽高
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,post
                        maxmin: true,
                        title: "基本信息",
                        content: "{:URL('project/Comment/basic')}?id="+id,
                        btn: ['关闭']
                    });
                    break;
                case 'parentName'://显示基本信息
                    if (parent_id == 0) {
                        break;
                    }
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['800px', '65%'], //宽高
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,post
                        maxmin: true,
                        title: "基本信息",
                        content: "{:URL('project/Comment/basic')}?id="+parent_id,
                        btn: ['关闭']
                    });
                    break;
                case 'subordinate': //显示下级项目
                    var library = obj.data.library;
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['80%', '70%'], //宽高
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,post
                        maxmin: true,
                        title: "基本信息",
                        content: "{:URL('/project/index/index')}?library="+library+"&parent_id="+id,
                        btn: ['关闭']
                    });
                    break;
                case 'edit':
                    modal.initialization({
                        url: "{:URL('project/power/detail')}",
                        type: "post",
                        data:{
                            id:id
                        }
                    });
                    break;
                case 'del':
                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/index/del')}";
                        let where = {id:id,library:library};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;
                case 'fixed':
                    modal.initialization({
                        url: "{:URL('project/figure/fixedDetail')}",
                        type: "post",
                        data:{
                            id:id
                        }
                    });
                    break;
                case 'taxableIncome':
                    modal.initialization({
                        url: "{:URL('project/figure/taxRevenueDetail')}",
                        type: "post",
                        data:{id:id,type:"taxableIncome"}
                    });
                    break;
                case 'setup':  //项目状态
                    modal.initialization({
                        url: "{:URL('project/figure/updateView')}",
                        type: "post",
                        data:{id:id,library:library}
                    });
                    break;
                case 'replyStatus': //项目状态(开工库)
                    modal.initialization({
                        url: "{:URL('project/figure/replyStatus')}",
                        type: "post",
                        data:{id:id,library:library}
                    });
                    break;
                case 'sign': //签约状态
                    modal.initialization({
                        url: "{:URL('project/figure/signView')}",
                        type: "post",
                        data:{id:id,library:library}
                    });
                    break;
                case 'start_status': //开工状态
                    modal.initialization({
                        url: "{:URL('project/figure/startView')}",
                        type: "post",
                        data:{id:id,library:library}
                    });
                    break;
                case 'warehousing': //入库状态
                    modal.initialization({
                        url: "{:URL('project/figure/warehousingView')}",
                        type: "post",
                        data:{id:id,library:library}
                    });
                    break;
                case 'reply': //启报状态
                    modal.initialization({
                        url: "{:URL('project/figure/replyView')}",
                        type: "post",
                        data:{id:id,library:library}
                    });
                    break;
                case 'progressList':
                    var type = $(this).attr("data-val");
                    var showUrl = "{:URL('project/Progress/index')}?pro_id="+id+'&group='+type;
                    if(type==1){
                        var title = "周报";
                    }else{
                        var title = "月报";
                    }
                    showView(showUrl,title);
                    break;
                case 'overseerList': //督查概况
                    var showUrl = "{:URL('project/Overseer/index')}?id="+id;
                    overseerView(showUrl);
                    break;
            }
        });

        //头工具栏事件
        table.on('toolbar(demo)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'export':
                    var data=$("form[name='searchForm']").serializeArray();
                    var dataVal = {type:'list',id:pid};
                    var exportUrl = "{:URL('project/excel/business_excel')}?library="+library;
                    $.each(data, function(i, item){
                        exportUrl = exportUrl+"&"+item.name+"="+item.value;
                        // dataVal[item.name] = item.value;
                    });

                     window.location.href=exportUrl;
                    break;
                case 'sqkExcel':
                    var data=$("form[name='searchForm']").serializeArray();
                    var dataVal = {type:'list',id:pid};
                    var exportUrl = "{:URL('project/excel/sqkExcel')}?library="+library;
                    $.each(data, function(i, item){
                        exportUrl = exportUrl+"&"+item.name+"="+item.value;
                        // dataVal[item.name] = item.value;
                    });

                    window.location.href=exportUrl;
                    break;
                case 'add':
                    modal.initialization({
                        url: "{:URL('project/power/detail')}",
                        type: "post",
                    });
                    break;
                case 'upload':
                    $("#test3").click();
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }

                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/index/del')}";
                        let where = {id:id,library:library};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;
                case 'getBatch':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }
                    //开启下拉选择框
                    layer.open({
                        type: 2,
                        skin: 'layui-layer-demo', //样式类名
                        area: ['400px','300px'],            //宽度450px,高自适应
                        anim: 2,
                        shadeClose: false, //开启遮罩关闭,
                        maxmin: true,
                        title: "批量操作",
                        content:"{:URL('project/Communal/batchView')}",
                        btn:['确定','取消'],
                        yes: function (index,layero) {

                            var body = layer.getChildFrame('body', index);
                            var data = body.find("form").serializeArray();
                            data.push({name: "id", value: id});
                            $.ajax({
                                type: "post",
                                url: "{:URL('project/Communal/batchView')}",
                                data: data,
                                dataType: "json",
                                success: function (data) {
                                    if(data.code!=0){
                                        layer.alert(data.msg);
                                    }else{
                                        table.reload('demo')
                                        layer.close(index);
                                    }
                                }
                            });

                        },
                    });
                    break;
            };
        });


        //监听单元格编辑
        table.on('edit(demo)', function(obj){
            var value = obj.value; //得到修改后的值
            var id = obj.data.id;
            $.ajax({
                type: "post",
                url: "/common/Common/updateSort",
                data: {id: id,table:'project_pro',value:value},
                dataType: "json",
                success: function (data) {
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }
                }
            });
        });

        //监听启用禁用操作
        form.on('switch(sexDemo)', function(obj){
            var id = this.value;
            var state = obj.elem.checked;
            let url = "{:URL('common/together/clickStatus')}";

            if (state == true) {
                let data = {id:id,status:1,table:'project_power',content:1}
                //上线
                publicClickStatus(url,data);
            } else {
                let data = {id:id,status:2,table:'project_power',content:1}
                //下线
                publicClickStatus(url,data);
            }
        });

        //督查概况视图
        function overseerView(showUrl,title="督查概况"){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['80%','80%'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: title,
                content:showUrl,
                btn:['确定','取消'],
                yes: function (index) {
                    layer.close(index);
                },
            });
        }

        //点评列表视图
        function showView(showUrl,title="节点计划"){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['1000px','700px'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: title,
                content:showUrl,
                btn:['确定','取消'],
                yes: function (index) {
                    layer.close(index);
                    // var body = layer.getChildFrame('body', index);
                    // var data = body.find("form[name='saveForm']").serializeArray();
                    // var content = body.find("#content").html();
                    // data.push({name: "content", value: content});
                    // // data.push({name: "plan_id", value: plan_id});
                    // $.ajax({
                    //     type: "post",
                    //     url: handle,
                    //     data: data,
                    //     dataType: "json",
                    //     success: function (data) {
                    //         if(data.code!=0){
                    //             layer.alert(data.msg);
                    //         }else{
                    //             table.reload('demo')
                    //             layer.close(index);
                    //         }
                    //     }
                    // });
                },
            });
        }

        //触发二级联动
        form.on('select(menuTop)', function (data) {
            //触发联动
            var id = data.value;

            if (id == 1) {
                $(".cultivation").show();
                $(".condition").hide();
                $(".progress_val").hide();
                $(".leader_val").show()
            } else {
                $(".cultivation").hide();
                $(".condition").show();
                $(".progress_val").show();
                $(".leader_val").hide()
            }

            $.ajax({
                type: 'post',
                url: "{:URL('project/Communal/selType')}",
                data: {menuTop: id},
                dataType: 'JSON',
                success: function (res) {
                    var arr = res.list;
                    var html = '<option value="">请选择</option>';
                    $.each(arr, function (e, v) {
                        html += '<option value="' + v.id + '">' + v.name + '</option>';
                    });
                    $('select[name="enterprise"]').html(html);
                    form.render('select');
                },
                error: function (res) {
                }
            });

        });


        //统一modal执行保存action
        modal.on("add",function(data){
            var data=$(modal.getid()).find("form").serialize();
            $.ajax({
                type: "post",
                url: "{:URL('project/power/add')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }else{
                        table.reload('demo')
                        $(".modal-header .close").click();
                    }
                }
            });
        });

        //统一modal执行修改action
        modal.on("edit",function(data){
            var data=$(modal.getid()).find("form").serialize();
            $.ajax({
                type: "post",
                url: "{:URL('project/power/save')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }else{
                        table.reload('demo')
                        $(".modal-header .close").click();
                    }
                }
            });
        });

        //统一modal执行修改action
        modal.on("fixed",function(data){
            var data=$(modal.getid()).find("form[name='layui-form']").serializeArray();
            $.ajax({
                type: "post",
                url: "{:URL('project/figure/fixedApi')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }else{
                        table.reload('demo')
                        $(".modal-header .close").click();
                    }
                }
            });
        });

        //统一modal执行修改action
        modal.on("taxableIncome",function(data){
            var data=$(modal.getid()).find("form[name='layui-form']").serializeArray();
            $.ajax({
                type: "post",
                url: "{:URL('project/figure/taxRevenueApi')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }else{
                        table.reload('demo')
                        $(".modal-header .close").click();
                    }
                }
            });
        });



        //执行状态更新
        modal.on("update",function(data){
            var data=$(modal.getid()).find("form[name='layui-form']").serializeArray();
            $.ajax({
                type: "post",
                url: "{:URL('project/figure/updateDo')}",
                data: data,
                dataType: "json",
                success: function (data) {
                    if(data.code!=0){
                        layer.alert(data.msg);
                    }else{
                        table.reload('demo')
                        $(".modal-header .close").click();
                    }
                }
            });
        });
        layui.form.render('select');
    });
</script>
</body>
</html>
